<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@include file="/WEB-INF/templates/common/taglib.jsp"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <title>${title }</title>
     <link rel="stylesheet" href="${basePath}/static/bootstrap/css/bootstrap.css"/>
    <link href="${basePath}/static/css/basic.css" rel="stylesheet" type="text/css">
    <link href="${basePath}/static/css/login.css" rel="stylesheet" type="text/css">
    <link href="${basePath}/static/css/list.css" rel="stylesheet" type="text/css">
    <script  type="text/javascript" src="${basePath}/static/js/jquery.min.js"></script>
	<script  type="text/javascript" src="${basePath}/static/My97DatePicker/WdatePicker.js"></script>
	<script type="text/javascript" src="${basePath}/static/page/jqPaginator/jqPaginator.js"></script>
    <script type="text/javascript" src="${basePath}/static/layer/layer.js"></script>
<link href="${basePath}/static/layer/layer_defined.css" rel="stylesheet"
	type="text/css">
</head>
<body>
<!--头部-->
	<%@include file="/WEB-INF/templates/common/header.jsp"%>
	<!------导航条-->
	<%@include file="/WEB-INF/templates/common/navigation.jsp"%>

<!--内容部分-->
<div class="list_main lay_out" class="clearfix">
    <div class="list_DH">
        <%@include file="/WEB-INF/templates/common/inhospitalDisease.jsp"%>
    </div>
    <div class="list_NR">
        <div class="loc">
            <h3 style="margin:0" >入院途径构成</h3>
        </div>
        <div class="list_con_table">
            <div class="search_table" style="position: relative; z-index: 999;">
                <ul class="clearfix" style="margin-bottom:0;">
                <li class="Label_1" >出院日期：&nbsp;</li>
                    <li class="Label_4" style="text-align:left;padding-left:3px;width:280px">
                    	<input class="Wdate input" style="width:120px;" type="text"  name='startTime' id='outHospitalStartDate' value='' onFocus="WdatePicker()" />
                    	<span>&nbsp;-&nbsp;</span>
                    	<input class="Wdate input" type="text" style="width:120px;"  name='endTime' id='outHospitalEndDate' value='' onFocus="WdatePicker()" />
                    </li>
                  <li class="Label_5">
                        <div class="right" style="text-align:right">
                            <a onclick="tj()">统计</a>
                       		<a onclick="exportExcel()">导出</a>	
                        </div>
                    </li>
                    
                </ul>
            </div> 
            <div id="chartmain" style="width:100%; height:520px; padding-bottom: 90px;"></div>
        
        </div>
        <!--
        	 <div class="pageList">
	            <ul class="pagination clearfix" id="page_plus"></ul>
	            <div class="pagination">
	                <div>总共：<b id="totalPage">0</b> 条信息    当前页是第 <b id="currentPage">0/0</b>　页</div>
	            </div>
      	  </div>
         -->
    </div>
</div>
<!------页脚部分--------->
<%@include file="/WEB-INF/templates/common/footer.jsp"%>
<script type="text/javascript" src="${pageContext.request.contextPath}/static/js/echatrs/echarts.min.js"></script>

<!--JS部分-->
<script type="text/javascript">
	
	function getOption(legendData, seriesData) {
		option = {
			    title : {
			        text: '入院途径',
			        x:'center'
			    },
			    tooltip : {
			        trigger: 'item',
			        formatter: "{a} <br/>{b} : {c}例 ({d}%)"
			    },
			    legend: {
			        orient: 'vertical',
			        left: 'left',
			        data:legendData //['急诊', '其他', '其他医疗机构转入', '门诊']
			    },
			    series : [
			        {
			            name: '入院途径',
			            type: 'pie',
			            radius : '70%',
			            center: ['50%', '60%'],
			            data:seriesData,
			           /*  [
			                {value:1478, name:'1-急诊'},
			                {value:602, name:'9-其他'},
			                {value:200, name:'3-其他医疗机构转入'},
			                {value:11241, name:'2-门诊'}
			            ], */
			            label: {
              	             normal: {
              	                 textStyle: {
              	                     fontSize: 14
              	                 },
              	                 formatter: function(param) {
              	                      return param.name + ':\n' + param.value + '例';
              	                 }
              	             }
			            },
			            itemStyle: {
			                emphasis: {
			                    shadowBlur: 10,
			                    shadowOffsetX: 0,
			                    shadowColor: 'rgba(0, 0, 0, 0.5)'
			                }
			            }
			        }
			    ]
			};	
			return option;
	}
	
	function tj() {
		 var legendData = []; 
		 var seriesData = [];
		 
		 $.ajax({
       	   async: false,//同步请求
       	   type:"get",
       	   data:{beginDate:$("#outHospitalStartDate").val(), endDate:$("#outHospitalEndDate").val()},
           url:"${pageContext.request.contextPath}/retrieval/admissionStatistics",
           success:function(result){
        		    console.log(result)
        		   var inHospitalTypeList = result.inHospitalTypeList;
        		   $.each(inHospitalTypeList, function(i, item){
        			   legendData.push(item.name);
        			   seriesData.push({value:0, name:item.name});
        		   });
        		  
        		  var admissionStatisticsList = result.admissionStatisticsList;
        		  //计算每个统计类别的总数量
        		  for (var i = 0; i < inHospitalTypeList.length; i++) {
        			  for(var j = 0; j < admissionStatisticsList.length; j++) {
        				  if(inHospitalTypeList[i].code == admissionStatisticsList[j].typeId) {
        					  seriesData[i].value = admissionStatisticsList[j].num;
        				  }
        			  }
        		  }
        		  
        		 var option = getOption(legendData, seriesData);
        		 //初始化echarts实例
        	     var myChart = echarts.init(document.getElementById('chartmain'));
        	     //使用制定的配置项和数据显示图表
        	     myChart.setOption(option);
        	     
        	    } //------success end------
          });
		 /*------------ajax end--------------*/
		
	}
	
	function exportExcel(){
		var outHospitalStartDate = $("#outHospitalStartDate").val();
		var outHospitalEndDate = $("#outHospitalEndDate").val();
		if(!outHospitalStartDate && !outHospitalEndDate){
			layer.alert("请输入查询条件!", {
				icon : 0
			});
			return;
		}
		
		
		
		
		window.location.href="${pageContext.request.contextPath}/retrieval/exportInHospitalRouteExcel?beginDate="+outHospitalStartDate+"&endDate="+outHospitalEndDate;
		 
	}
	
	
	
	
	
</script>


</body>
</html>